<!DOCTYPE html>
<body>
    <video>
        <track kind="captions" onload="loaded()" onerror="errored()">
    </video>

    <script>
        function loaded() {
            alert("Loaded successfully.");
            if (window.opener)
                window.opener.postMessage('done', '*');
        }
        function errored() {
            alert("Failed to load.");
            if (window.opener)
                window.opener.postMessage('done', '*');
        }
        window.onload = function () {
            var track = document.querySelector('track');
            var video = document.querySelector('video');
            track.track.mode = "hidden";
            url = "http://example.test:8000/security/resources/captions-with-access-control-headers.php?origin=1";
            video.setAttribute('crossorigin', 'anonymous');
            track.setAttribute('src', url);
        };
    </script>
</body>
